package com.zpeb.pdd.utils;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: qiuzp
 * @Date: 2019/1/13 0013 1:15
 * @Description:
 */
public class Msg implements Serializable {
    private String sendID;
    private String ReciveID;
    private String code;
    //提示信息
    private String msg;

    public String getSendID() {
        return sendID;
    }

    public void setSendID(String sendID) {
        this.sendID = sendID;
    }

    public String getReciveID() {
        return ReciveID;
    }

    public void setReciveID(String reciveID) {
        ReciveID = reciveID;
    }

    //用户要返回给浏览器的数据
    private Map<String, Object> data = new HashMap<String, Object>();

    public static Msg success(){
        Msg result = new Msg();
        result.setCode("200");
        result.setMsg("处理成功！");
        return result;
    }

    public static Msg fail(){
        Msg result = new Msg();
        result.setCode("400");
        result.setMsg("处理失败！");
        return result;
    }
    public static Msg notFound(){
        Msg result = new Msg();
        result.setCode("404");
        result.setMsg("网页未找到！");
        return result;
    }
    public static Msg authFail(){
        Msg result = new Msg();
        result.setCode("403");
        result.setMsg("权限不足！");
        return result;
    }

    public static Msg noHeards(){
        Msg result = new Msg();
        result.setCode("401");
        result.setMsg("请求头为空！");
        return result;
    }

    public static Msg loginFail(){
        Msg result = new Msg();
        result.setCode("403");
        result.setMsg("登录失败！");
        return result;
    }


    public Msg add(String key,Object value){
        this.getData().put(key, value);
        return this;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }


    @Override
    public String toString() {
        return "Msg{" +
                "code='" + code + '\'' +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
